/*
 * Copyright (c) Created by T C L on 2019.7.9.
 */

package cn.mumzone.pos.presenter;

import android.content.Context;

import cn.mumzone.basic.net.http.callback.ApiCallBack;
import cn.mumzone.basic.net.response.BaseResponse;
import cn.mumzone.basic.util.ToastUtil;
import cn.mumzone.pos.model.TimeCardEntity;
import cn.mumzone.pos.model.source.MemberRepository;
import cn.mumzone.pos.presenter.contract.TimesCardDetailContract;

public class TimesCardDetailPresenter implements TimesCardDetailContract.Presenter {


    private TimesCardDetailContract.View view;

    private Context context;

    private MemberRepository memberRepository;

    public TimesCardDetailPresenter(Context context, TimesCardDetailContract.View view) {
        this.context = context;
        this.view = view;
        memberRepository = new MemberRepository();
    }


    @Override
    public void requestCardConsumeInfo(String cardId) {
        memberRepository.getTimeCardDetail(cardId, new ApiCallBack<TimeCardEntity>() {
            @Override
            public void onSuccess(TimeCardEntity timeCardEntity) {
                view.setCardConsumeInfo(timeCardEntity);
            }

            @Override
            public void onError(BaseResponse response) {
                ToastUtil.makeText(context, response.getMsg(), false);
            }
        });
    }
}
